1. Technology Field
The present invention relates to a data writing method for a rewritable non-volatile memory module, and a memory controller and a memory storage apparatus using the same.
2. Description of Related Art
Along with the widespread of digital cameras, cell phones, and MP3 in recently years, the consumers' demand to storage media has increased drastically. Rewritable non-volatile memory is one of the most adaptable storage media to portable electronic products (for example, cell phones, personal digital assistants (PDAs), and notebook computers) due to its many characteristics such as data non-volatility, low power consumption, small volume, non-mechanical structure, and high access speed. For example, a solid state drive (SSD) is a storage apparatus which uses a flash memory as its storage medium. Thus, in recent years, the flash memory industry has become a major part of the electronic industry.
A rewritable non-volatile memory module has a plurality of physical blocks, and each of the physical blocks has a plurality of physical pages. While writing data into a physical block, the data has to be written according to the sequence of the physical pages in the physical block. In addition, a physical page already containing data has to be erased before it is used for writing a new data. Particularly, physical block is the smallest unit for erasing data, and physical page is the smallest unit for programming (i.e., writing) data.
In order to increase the operation efficiency, a memory controller of a memory storage apparatus may group the physical blocks of a rewritable non-volatile memory module into a data area and a spare area.
Physical blocks in the data area are used for storing data written by a host system. To be specific, a memory management circuit converts a logical access address accessed by the host system into a logical page of a logical block and maps the logical page of the logical block to a physical page of a physical block in the data area. Namely, in the management of a flash memory module, the physical blocks in the data area are considered used physical blocks (for example, already containing data written by the host system). In addition, the memory management circuit records the mapping relationship between the logical blocks and the physical blocks in the data area in a logical block-physical block mapping table, wherein the logical pages of a logical block are sequentially mapped to the physical pages of the corresponding physical block.
Physical blocks in the spare area are used for substituting physical blocks in the data area. To be specific, a physical block already containing data has to be erased before it is used for writing new data, and a physical block in the spare area is used for writing updated data to substitute the physical block originally mapped to a logical block. Accordingly, the physical blocks in the spare area are either blank or available blocks (i.e., no data is recorded therein or data recorded therein is marked as invalid data).
Namely, when the storage space of a memory storage apparatus is formatted, physical blocks in the data area are mapped to logical blocks and considered already containing updated data. Subsequently, when a host system is about to store data into a logical page of a logical block, the memory controller selects a blank physical block from the spare area and writes the data into a physical page of the selected physical block, so as to complete the data update in the logical page. However, as described above, physical page is the smallest unit for programming (i.e., writing) data. Thus, when the host system is about to update only a part of the data in a logical page (i.e., the size of data to be written is smaller than a page capacity), the memory controller needs to read old valid data from the physical page originally mapped to the logical page, arranges the updated data and the old valid data to generate a complete valid page data, and then writes the valid page data into the blank physical page.
Along with the development of semiconductor technologies, the page capacity of each physical page in rewritable non-volatile memory modules has been increasing. For example, each physical page in an existing rewritable non-volatile memory module is usually designed to store 8 kilobytes (KB) of user data (i.e., the capacity of each page is 8 KB). However, the operating system (OS) of a host system (for example, a personal computer) usually stores data in a smaller unit. For example, the MS Windows 7 operating system always stores 4 KB of data. Thus, a memory controller needs to read and arrange valid data frequently in order to write data into physical pages, which seriously affects the writing speed of a memory storage apparatus.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.